package org.jb.coinche.server;

import org.jb.coinche.client.business.model.Game;
import org.jb.coinche.client.guistatemachine.StateService;
import org.jb.coinche.server.business.GameDisconnectListener;
import org.jb.coinche.server.business.transition.AuctionTurnTransition;
import org.jb.coinche.server.business.transition.GameReadyTransition;
import org.jb.coinche.server.business.transition.RoundTurnFinishedTransition;
import org.jb.coinche.server.business.transition.RoundTurnTransition;
import org.jb.coinche.server.notify.NotificationProvider;
import org.jb.coinche.server.rooms.RoomScoped;
import org.jb.coinche.server.statemachine.InitialState;
import org.jb.coinche.server.statemachine.StateMachine;
import org.jb.coinche.server.statemachine.Transition;
import org.jb.coinche.server.statemachine.impl.StateMachineImpl;
import org.jb.coinche.server.statemachine.impl.StateMachineNotificationProvider;
import org.jb.coinche.server.statemachine.service.StateServiceImpl;
import org.jb.coinche.server.user.room.RoomUsersListener;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

/**
 * 
 * @author jeremie
 *
 */
public class CoincheModule extends AbstractModule {

	/**
	 * 
	 */
	@Override
	protected void configure() {
		
		bind(StateService.class).to(StateServiceImpl.class);
		bind(StateMachine.class).to(StateMachineImpl.class).in(RoomScoped.class);
		
		bind(Object.class).annotatedWith(InitialState.class).to(Game.class);
		
		Multibinder<Transition> multiBinder = Multibinder.newSetBinder( binder(), Transition.class );
		multiBinder.addBinding().to(AuctionTurnTransition.class);
		multiBinder.addBinding().to(GameReadyTransition.class);
		multiBinder.addBinding().to(RoundTurnFinishedTransition.class);
		multiBinder.addBinding().to(RoundTurnTransition.class);
		
		Multibinder<NotificationProvider> notifications = Multibinder.newSetBinder( binder(), NotificationProvider.class );
		notifications.addBinding().to(StateMachineNotificationProvider.class).in(RoomScoped.class);
		
		Multibinder<RoomUsersListener> usersListener = Multibinder.newSetBinder(binder(), RoomUsersListener.class);
		usersListener.addBinding().to(GameDisconnectListener.class);
	}

	
}

